package com.jwdf.uda.http.action;

import android.content.Context;

import com.jwdf.uda.bean.PbBean;
import com.jwdf.uda.http.AHttpTaskService;
import com.jwdf.uda.http.ApiService;

import java.util.List;

import retrofit2.Call;

/**
 * Created by Administrator on 2016/9/7.
 */
public class QuestionAddAction extends AHttpTaskService<PbBean.PbResQuestionAddQuestion> {


    private String mTitle;
    private int mCategoryCode;
    private List<PbBean.PbBaseReqDescription> mDescriptionList;
    private List<PbBean.PbBaseReqVoteOption>  mVoteOptionList;
    private QuestionAddAction(Context context, String  title, int categoryCode, List<PbBean.PbBaseReqDescription> descriptionList, List<PbBean.PbBaseReqVoteOption>  voteOptionList ,int i) {
        super(context ,i);
        this.mTitle=title;
        this.mCategoryCode=categoryCode;
        this.mDescriptionList=descriptionList;
        this.mVoteOptionList=voteOptionList;
    }
    /**
     * 新增问题
     *
     * @param context
     * @param title
     * @param categoryCode
     * @param descriptionList
     * @param voteOptionList
     *
     * @return
     */
    public static QuestionAddAction newInstance(Context context, String title, int categoryCode, List<PbBean.PbBaseReqDescription> descriptionList, List<PbBean.PbBaseReqVoteOption> voteOptionList, int i) {
        return new QuestionAddAction(context, title, categoryCode, descriptionList, voteOptionList, i);
    }
    @Override
    protected Call newRetrofitCall(ApiService apiService, PbBean.PbBaseClientInfo.Builder baseBuilder) {
        PbBean.PbReqQuestionAddQuestion.Builder builder = PbBean.PbReqQuestionAddQuestion.newBuilder();
        builder.setBaseClientInfo(baseBuilder);
        builder.setTitle(mTitle);
        builder.setCategoryCode(mCategoryCode);
        builder.addAllDescription(mDescriptionList);
        builder.addAllVoteOption(mVoteOptionList);
        return apiService.quizAdd(builder.build());
    }
}
